package com.luojilab.share.runalone.application

import android.annotation.TargetApi
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Build
import android.support.multidex.MultiDex
import com.luojilab.component.componentlib.router.Router
import com.tencent.tinker.loader.app.DefaultApplicationLike

/**
 * Created by mrzhang on 2017/6/15.
 *
 *
 * edit by samge on 2018/07/06
 */
class ApplicationLike(application: Application, tinkerFlags: Int,
                      tinkerLoadVerifyFlag: Boolean, applicationStartElapsedTime: Long,
                      applicationStartMillisTime: Long, tinkerResultIntent: Intent) : DefaultApplicationLike(application, tinkerFlags, tinkerLoadVerifyFlag, applicationStartElapsedTime, applicationStartMillisTime, tinkerResultIntent) {

    override fun onCreate() {
        super.onCreate()
        //如果isRegisterCompoAuto为false，则需要通过反射加载组件
        Router.registerComponent("com.luojilab.share.applike.ShareApplike")
        Router.registerComponent("com.luojilab.share.kotlin.applike.KotlinApplike")
    }

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    override fun onBaseContextAttached(base: Context?) {
        super.onBaseContextAttached(base)
        MultiDex.install(base)
    }

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    fun registerActivityLifecycleCallback(callbacks: Application.ActivityLifecycleCallbacks) {
        application.registerActivityLifecycleCallbacks(callbacks)
    }
}
